package com.atguigu.mvc.exception;

import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.ControllerAdvice;
import org.springframework.web.bind.annotation.ExceptionHandler;

/**
 * 异常处理类
 *
 * @author superHao
 * @date 2022/12/12
 */
@ControllerAdvice
public class TestException {

    @ExceptionHandler(value = {
            ArithmeticException.class,
            NullPointerException.class
    })
    public String testException(java.lang.Exception ex, Model model) {
        model.addAttribute("ex", ex);
        return "error";
    }
}
